<!-- 解除车位绑定-->
<template>
	<view>
		<view>

			<view class="block__title">车位信息</view>
			<view class="cu-form-group">
				<view class="title">车位编号</view>
				{{roomDetail.psName}}
			</view>
			<view class="cu-form-group">
				<view class="title">产权类型</view>
				{{roomDetail.propertyType}}
			</view>
			<view class="cu-form-group">
				<view class="title">车牌号</view>
				{{plate}}
			</view>
			
			
			<view class="cu-form-group" v-if="roomDetail.propertyType == 1">
				<view class="title">产权类型</view>
				已售
			</view>
			<view class="cu-form-group" v-if="roomDetail.propertyType == 2">
				<view class="title">产权类型</view>
				未售
			</view>
			<view class="cu-form-group" v-if="roomDetail.propertyType == 3">
				<view class="title">产权类型</view>
				出租
			</view>

			<view class="bottomRegion">
				<view class="vacantHouse">
					<button @click="changeContent(roomDetail)" type="primary">修改车牌号</button>
					<!-- <button @click="houseUnbundling" type="warn">解除车位绑定</button> -->
				</view>
			</view>


			<view class="cu-modal" :class="delOwnerMemberFlag==true?'show':''">
				<view class="cu-dialog">
					<view class="cu-bar bg-white justify-end">
						<view class="content">温馨提示</view>
						<view class="action" @tap="_cancleCall()">
							<text class="cuIcon-close text-red"></text>
						</view>
					</view>
					<view class="padding-xl">
						您确认解除该成员车位申请？
					</view>
					<view class="cu-bar bg-white justify-end">
						<view class="action margin-0 flex-sub  solid-left" @tap="_cancleDeleteOwnerMember()">取消</view>
						<view class="action margin-0 flex-sub text-green solid-left" @tap="_doDeleteOwnerMember()">确认
						</view>
					</view>
				</view>
			</view>
		</view>

		<view>
			<!-- 普通弹窗 -->
			<uni-popup ref="popup" background-color="#fff" isButton>
				<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
					<view class="" style="width: 540rpx;height: 260rpx;background-color: white;">
						<view class="cu-form-group">

							<view class="cu-form-group">
								<view class="title">车牌号</view>
								<input v-model="plate" style="text-align:right" placeholder="请输入车牌号"></input>
							</view>
						</view>
						<view class="btn">
							<button type="warn" @click="cancelCar">取消</button>
							<button type="primary" @click="ensure">确认</button>
						</view>
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	const factory = context.factory;
	import {
		deleteCarBind
	} from '../../api/owner/ownerApi.js'

	export default {
		data() {
			return {
				cqrid: '', //车权人id
				plate: '',
				type: '',
				examineObjectId: '',
				carDetails: '',
				plateNumber: '',
				psId: '',
				changePsId: false,
				isButton: true,
				stepsData: '',
				delOwnerMemberFlag: false, //解除房屋绑定弹窗
				ownerInfo: {},
				// 用户信息
				userInfo: {},
				// 用户信息
				ownerFlag: false,
				// 是否有业主信息 标记 如果有为 true  没有为false
				roomDetail: {},
				curOwnerMember: {},
				listId: {},
				plotCommunityId: '',
				identityType: "",
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			let _that = this;
			_that.roomDetail = JSON.parse(options.room);
			_that.plate = _that.roomDetail.plate
			_that.cqrid = _that.roomDetail.id
			console.log("_that.roomDetail", _that.roomDetail, "车圈人id", _that.cqrid)
		},

		methods: {
			changeContent(parkNumber) {
				this.type = 'center'
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open("center")
			},
			cancelCar() {
				uni.navigateBack({
					url: "pagesA/parkingInfo/carNumber"
				})
				this.$refs.popup.close()
			},
			ensure() {
				let _that = this;
				uni.request({
					url: constant.url.changeCarId,
					header: context.getHeaders(),
					method: "POST",
					data: {
						// proprietorId: 60,
						id: _that.cqrid,
						plate: _that.plate,
					},
					success: function(res) {
						let _json = res.data;
						_that.delOwnerMemberFlag = false;
						_that.$refs.popup.close()
						// that._loadFamilyList();
						wx.showToast({
							title: "成功",
							icon: 'none',
							duration: 2000
						});
					},
					fail: function(e) {
						_that.$refs.popup.close()
						wx.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			loadOwenrInfo: function() {
				let _that = this;

				context.getOwner(function(_ownerInfo) {
					console.log(_ownerInfo);

					if (_ownerInfo) {
						_that.ownerFlag = true;
						_that.ownerInfo = _ownerInfo;
					} else {
						_that.ownerFlag = false;
					}
				});
			},
			// 解除车位绑定
			houseUnbundling: function(item) {
				this.delOwnerMemberFlag = true;
				this.curOwnerMember = item;
			},
			_cancleDeleteOwnerMember: function(item) {
				this.delOwnerMemberFlag = false;
			},
			_doDeleteOwnerMember: function() {
				let that = this;
				uni.request({
					url: constant.url.deleteOwnerCar,
					header: context.getHeaders(),
					method: "POST",
					data: {
						proprietorId: 60,
						psId: that.psId,
						id: that.listId,
					},
					success: function(res) {
						console.log("res车位", res)
						let _json = res.data;
						// if (_json.code == 0) {
						// 	uni.redirectTo({
						// 		url: '../parkingInfo/myParking',
						// 	});
						// 	return;
						// }
						that.delOwnerMemberFlag = false;
						wx.showToast({
							title: "修改成功",
							icon: 'none',
							duration: 2000
						});
					},
					fail: function(e) {
						wx.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						});
					}
				})
			}
		}
	};
</script>
<style scoped lang="scss">
	@import "@/pagesB/my/myHouseDetail.css";

	text {
		text-align: center;
	}

	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}

	.change_content {
		text-align: right;
		float: right;
	}

	.cu-form-group input {
		padding-right: 0rpx;
	}

	.bottomRegion {
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		.vacantHouse {
			margin: 20rpx;
			width: 100%;
			text-align: center;
			height: 60rpx;
			display: flex;
			justify-content: space-around;
			font-size: 26rpx;
			line-height: 60rpx;

			button {
				float: left;
				width: 300rpx;
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx;
			}
		}

	}

	.btn {
		display: flex;
		justify-content: space-around;
		margin-top: 40rpx;

		button {
			width: 100rpx;
			height: 50rpx;
			font-size: 18rpx;
			border-radius: 30rpx;
		}
	}
</style>
